// ViewYourFolder.cpp : implementation file
//

#include "stdafx.h"
#include "ViewYourFolder.h"


// ViewYourFolder

IMPLEMENT_DYNCREATE(CViewYourFolder, CView)

CViewYourFolder::CViewYourFolder()
{
	m_pFolderTree = 0;
}

CViewYourFolder::~CViewYourFolder()
{
	if(m_pFolderTree != 0)
	{
		delete m_pFolderTree;
		m_pFolderTree = 0;
	}
}

BEGIN_MESSAGE_MAP(CViewYourFolder, CView)
END_MESSAGE_MAP()

// ViewYourFolder drawing

void CViewYourFolder::OnDraw(CDC* pDC)
{
	CDocument* pDoc = GetDocument();
	// TODO: add draw code here
}

// ViewYourFolder diagnostics

#ifdef _DEBUG
void CViewYourFolder::AssertValid() const
{
	CView::AssertValid();
}

#ifndef _WIN32_WCE
void CViewYourFolder::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}
#endif
#endif //_DEBUG


// ViewYourFolder message handlers

void CViewYourFolder::OnInitialUpdate()
{
	CView::OnInitialUpdate();

	this->CreateFolderTree();
}

void CViewYourFolder::CreateFolderTree()
{
	//Get current rectangle
	CRect rect;
    GetClientRect(rect);

	//If folder tree is existed
	if (m_pFolderTree != 0)
    {
		//Remove folder tree
		m_pFolderTree->DestroyWindow();
		delete m_pFolderTree;
    }

	//Initilize folder tree
	m_pFolderTree = new CFolderTree2D;
	//Draw folder tree
	m_pFolderTree->CreateFolderTree(ROW_NUM, COL_NUM, rect, this);
}
